/**
 * 
 */
package com.zy.cat.controller.dev.v1;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.Callable;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zy.cat.common.annotation.CheckDevPermission;
import com.zy.cat.common.annotation.CheckingMD5;
import com.zy.cat.common.utils.DateAPIUtils;
import com.zy.cat.entity.dev.CatDevTreeTaskRecord;
import com.zy.cat.entity.dev.CatDevUserInfo;
import com.zy.cat.entity.dev.CatDevUserTaskRecord;
import com.zy.cat.entity.dev.act.CatDailyDrawAwardeeOrder;
import com.zy.cat.entity.dev.act.CatDailyDrawResult;
import com.zy.cat.entity.dev.act.resp.CatDailyDrawAwardeeOrderResp;
import com.zy.cat.entity.dev.act.resp.CatDailyDrawDetailResp;
import com.zy.cat.entity.dev.garden.CatTreeOrder;
import com.zy.cat.entity.dev.garden.CatTreeResult;
import com.zy.cat.entity.dev.garden.CatUserTree;
import com.zy.cat.entity.dev.garden.CatUserTreeGrade;
import com.zy.cat.entity.dev.garden.CatUserTreeTask;
import com.zy.cat.entity.dev.garden.Tree;
import com.zy.cat.entity.dev.garden.repository.CatTreeOrderRepository;
import com.zy.cat.entity.dev.garden.repository.TreeResultRepository;
import com.zy.cat.entity.dev.garden.resp.CatTreeDetailResp;
import com.zy.cat.entity.dev.garden.resp.CatTreeOrderResp;
import com.zy.cat.entity.dev.garden.resp.CatUserTreeGradeResp;
import com.zy.cat.entity.dev.garden.resp.CatUserTreeResp;

import com.zy.cat.entity.dev.garden.resp.CatUserTreeTaskRewardResp;
import com.zy.cat.entity.dev.garden.resp.CatUserTreeWateringResp;
import com.zy.cat.entity.dev.repository.CatDevTreeTaskConfigRepository;
import com.zy.cat.entity.dev.repository.CatDevTreeTaskRecordRepository;
import com.zy.cat.entity.dev.repository.CatDevUserTaskRecordRepository;
import com.zy.cat.entity.dev.resp.CatDevBeanVideoHistoryResp;
import com.zy.cat.entity.dev.resp.CatDevFertilizerVideoHistoryResp;
import com.zy.cat.entity.dev.resp.CatDevOrderResp;
import com.zy.cat.entity.dev.resp.CatDevReRedHistoryResp;
import com.zy.cat.entity.dev.resp.CatDevWelfareInfoResp;
import com.zy.cat.entity.dev.resp.CatDevWelfareInfoResp.UserTaskData;
import com.zy.cat.entity.resp.Pages;
import com.zy.cat.entity.resp.RSPE;
import com.zy.cat.entity.resp.ResultPage;
import com.zy.cat.service.CacheService;
import com.zy.cat.service.CatDevTreeService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * @author sunyuancui
 * @date   2020年12月24日
 * 
 */
@Slf4j
@RestController
@RequestMapping("/v1/user/garden")
@Api(value = "9catDevUser", tags = { "9趣猫果树管理API" }, description = "9趣猫果树管理接口")
public class CatDevTreeController {
	
	@Autowired
	CatDevTreeService catDevTreeService;
	
	@Autowired
	CacheService cacheService;
	
	@Autowired
	TreeResultRepository treeResultRepository;
	
	@Autowired
	CatDevTreeTaskConfigRepository catDevTreeTaskConfigRepository;
	
	@Autowired
	CatDevTreeTaskRecordRepository newTreeTaskRecordRepository;
	
	@Autowired
	CatTreeOrderRepository catTreeOrderRepository;
	
	@PostMapping("/list")
	@ApiOperation(value = "获取用户果园数据", notes = "获取用户果园数据", consumes = "application/x-www-form-urlencoded", position = 5, response = CatUserTreeResp.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "rtype", value = "应用平台(0.安卓、1.IOS)", example = "0", required = true, dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "pid", value = "用户登录时的返回字段", example = "5380881829", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "utoken", value = "用户登录时的返回字段", example = "1001", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "uuid", value = "MD5(随机数)", example = "27b8f8538f84fa456f783e600c27dd18", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "token", value = "MD5(rtype_pid_utoken_uuid_time)", example = "1001", required = true, dataType = "String", paramType = "form") })
	@CheckDevPermission
	//@CheckingMD5(checkingStr = "rtype_pid_utoken_uuid", MD5 = "token")
	public Object getTreeData(Integer rtype, String pid,String utoken, String uuid, String token) {
		if (rtype == null || (rtype != 0 && rtype != 1)) {
			return new RSPE<Object>(-3, "应用平台参数错误！");
		}if (StringUtils.isBlank(pid)) {
			return new RSPE<String>(-2, "pid不能为空！");
		}
		Callable<RSPE<List<CatUserTreeResp>>> result = new Callable<RSPE<List<CatUserTreeResp>>>() {
			@Override
			public RSPE<List<CatUserTreeResp>> call() throws Exception {
				List<CatUserTreeResp>  resp =catDevTreeService.getTreeData(rtype,pid);
				if (resp != null) {
					return new RSPE<List<CatUserTreeResp>>(resp);
				}
				return new RSPE<List<CatUserTreeResp>>(-1, "获取失败！");
			}
		};			
		return result;
	}	
	

	@PostMapping("/task")
	@ApiOperation(value = "获取用户果园任务数据", consumes = "application/x-www-form-urlencoded", position = 15, notes = "获取用户果园任务数据", response = CatUserTreeResp.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "rtype", value = "应用平台(0.安卓、1.IOS)", example = "0", required = true, dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "pid", value = "登录返回字段", example = "5516603495", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "uuid", value = "MD5(随机数)", example = "27b8f8538f84fa456f783e600c27dd18", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "utoken", value = "登录返回字段", example = "1001", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "token", value = "MD5(rtype_pid_uuid_utoken_time)", example = "8f85345627bf783e6008f84fac27dd18", required = true, dataType = "String", paramType = "form") })
	//@CheckingMD5(checkingStr = "rtype_pid_uuid_utoken", MD5 = "token", checkSingle = true)
	@CheckDevPermission
	public Object getTreeTask(Integer rtype, String pid,String uuid, String utoken, String token) {
		if (rtype == null || (rtype != 0 && rtype != 1)) {
			return new RSPE<Boolean>(-2, "应用平台参数错误！");
		}
		/* 查看用户是否存在 */
		CatDevUserInfo zdev = catDevTreeService.getCatDevUserInfoByPid(pid);
		if (zdev == null) {
			return new RSPE<Boolean>(-4, "错误:用户信息不存在！");
		}
		/* 查看用户今日已领取次数 */
		Callable<RSPE<CatUserTreeResp>> result = new Callable<RSPE<CatUserTreeResp>>() {
			//获取任务
			@Override
			public RSPE<CatUserTreeResp> call() throws Exception {
				CatUserTreeResp resp =catDevTreeService.getTreeTask(rtype, pid);
				if (resp != null) {
					return new RSPE<CatUserTreeResp>(resp);
				}
				return new RSPE<CatUserTreeResp>(-1, "获取失败！");
			}
		};
		return result;
	}
	
	@PostMapping("/level")
	@ApiOperation(value = "获取果树等级信息", notes = "获取果树等级信息", consumes = "application/x-www-form-urlencoded", position = 5, response = CatUserTreeGradeResp.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "rtype", value = "应用平台(0.安卓、1.IOS)", example = "0", required = true, dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "utoken", value = "用户登录时的返回字段", example = "1001", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "uuid", value = "MD5(随机数)", example = "27b8f8538f84fa456f783e600c27dd18", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "token", value = "MD5(rtype_utoken_time)", example = "1001", required = true, dataType = "String", paramType = "form") })
	@CheckDevPermission
	//@CheckingMD5(checkingStr = "rtype_utoken_uuid_pid", MD5 = "token")
	public Object getTreeLevel(Integer rtype,String utoken, String uuid, String token) {
		if (rtype == null || (rtype != 0 && rtype != 1)) {
			return new RSPE<Object>(-3, "应用平台参数错误！");
		}
		Callable<RSPE<CatUserTreeGradeResp>> result = new Callable<RSPE<CatUserTreeGradeResp>>() {
			@Override
			public RSPE<CatUserTreeGradeResp> call() throws Exception {
				return new RSPE<CatUserTreeGradeResp>(catDevTreeService.getTreeLevel());
			}
		};
		return result;
	}	
	
	@PostMapping("/water")
	@ApiOperation(value = "用户浇水", notes = "用户浇水", consumes = "application/x-www-form-urlencoded", position = 5, response = CatUserTreeResp.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "rtype", value = "应用平台(0.安卓、1.IOS)", example = "0", required = true, dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "pid", value = "登录返回字段", example = "8982895590", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "onceFertilizer", value = "施肥数量", example = "600", dataType = "Integer", paramType = "form"),
			@ApiImplicitParam(name = "utoken", value = "用户登录时的返回字段", example = "1001", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "uuid", value = "MD5(随机数)", example = "27b8f8538f84fa456f783e600c27dd18", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "token", value = "MD5(rtype_pid_onceFertilizer_utoken_time)", example = "1001", required = true, dataType = "String", paramType = "form") })
	@CheckDevPermission
	//@CheckingMD5(checkingStr = "rtype_pid_onceFertilizer_utoken_uuid", MD5 = "token")
	public Object getWatering(Integer rtype,String pid,Integer onceFertilizer, String utoken, String uuid, String token) {
		if (rtype == null || (rtype != 0 && rtype != 1)) {
			return new RSPE<Object>(-3, "应用平台参数错误！");
		}if (StringUtils.isBlank(pid)) {
			return new RSPE<String>(-2, "pid不能为空！");
		}
		Callable<RSPE<List<CatUserTreeResp>>> result = new Callable<RSPE<List<CatUserTreeResp>>>() {
			@Override
			public RSPE<List<CatUserTreeResp>> call() throws Exception {
				return new RSPE<List<CatUserTreeResp>>(catDevTreeService.getWatering(rtype,pid,onceFertilizer));
			}
		};
		return result;
	}	
	
	@PostMapping("/tree/reward")
	@ApiOperation(value = "获取用户果园任务奖励", notes = "获取用户果园任务奖励", consumes = "application/x-www-form-urlencoded", position = 5, response = CatUserTreeTask.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "rtype", value = "应用平台(0.安卓、1.IOS)", example = "0", required = true, dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "pid", value = "登录返回字段", example = "5516603495", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "taskType", value = "每日任务类型（10.签到、11.看视频、12.参加免费抽、13.浏览猜你喜欢、14.购买商品、15.分享微信、16.领取优惠券、17.前往游戏、18.复制商品标题）；新人任务类型（0.新用户首次奖励、1.新手教程、2.完善手机号、3.绑定公众号、4.新人首单）", example = "0", dataType = "Integer", paramType = "form"),
			@ApiImplicitParam(name = "utoken", value = "用户登录时的返回字段", example = "1001", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "uuid", value = "MD5(随机数)", example = "27b8f8538f84fa456f783e600c27dd18", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "token", value = "MD5(rtype_pid_taskType_utoken_time)", example = "1001", required = true, dataType = "String", paramType = "form") })
	@CheckDevPermission
	//@CheckingMD5(checkingStr = "rtype_pid_taskType_utoken_uuid_pid", MD5 = "token")
	public Object getTaskReward(Integer rtype,String pid,Integer taskType, String utoken, String uuid, String token) {
		if (rtype == null || (rtype != 0 && rtype != 1)) {
			return new RSPE<Object>(-3, "应用平台参数错误！");
		}
		if (taskType==null || taskType<0) {
			return new RSPE<CatUserTreeTask>(-3, "任务类型不存在！");
		}
		//判断任务类型是否存在
		if(catDevTreeTaskConfigRepository.findByTypeId(taskType)==null) {
			return new RSPE<CatUserTreeTask>(-3, "任务类型不存在！");
		}
		
		//判断任务是否已完成
		CatDevTreeTaskRecord taskRecord = newTreeTaskRecordRepository.queryByPidAndTaskTypeOrderByTaskType(pid, taskType);
		if (taskRecord==null) {
			return new RSPE<CatUserTreeTask>(-4, "任务奖励不存在！");
		}
		if (taskRecord.getReceiveStatus()==1) {
			return new RSPE<CatUserTreeTask>(-5, "任务奖励已领取！");
		}
		
		//判断任务是否完成
		if (taskRecord.getTaskType()==4) {
			//判断用户是否已经有订单记录
			Integer number = cacheService.getOrderNumber(taskRecord.getPid(),taskRecord.getPid(),null);
			if (number==null || number==0) {
				return new RSPE<CatUserTreeTask>(-6, "任务未完成！");
			}
		}else if (taskRecord.getTaskType()==0) {
			//每日首单奖励
			//判断用户是否已经有订单记录
			Integer number = cacheService.getOrderNumber(taskRecord.getPid()+LocalDate.now().toString(),taskRecord.getPid(),LocalDate.now().toString());
			if (number!=null && number>0) {
				return new RSPE<CatUserTreeTask>(-6, "任务未完成！");
			}
		}
		CatDevTreeTaskRecord task=taskRecord;
		Callable<RSPE<CatUserTreeTask>> result = new Callable<RSPE<CatUserTreeTask>>() {
			@Override
			public RSPE<CatUserTreeTask> call() throws Exception {
				CatUserTreeTask data = catDevTreeService.getTaskReward(rtype,pid, task);
				if (data != null) {
					return new RSPE<CatUserTreeTask>(data);
				}
				return new RSPE<CatUserTreeTask>(0, "领取失败！");
			}
		};
		return result;
	}
	
	@PostMapping("/tree")
	@ApiOperation(value = "开始种树", notes = "开始种树", consumes = "application/x-www-form-urlencoded", position = 5, response = CatUserTreeResp.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "rtype", value = "应用平台(0.安卓、1.IOS)", example = "0", required = true, dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "utoken", value = "用户登录时的返回字段", example = "1001", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "pid", value = "用户id", example = "5516603495", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "id", value = "果树id", example = "0", dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "uuid", value = "MD5(随机数)", example = "27b8f8538f84fa456f783e600c27dd18", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "token", value = "MD5(rtype_utoken_pid_id_time)", example = "1001", required = true, dataType = "String", paramType = "form") })
	@CheckDevPermission
	//@CheckingMD5(checkingStr = "rtype_utoken_pid_id_uuid", MD5 = "token")
	public Object getTree(Integer rtype,String pid,Integer id,String utoken, String uuid, String token) {
		if (rtype == null || (rtype != 0 && rtype != 1)) {
			return new RSPE<Object>(-3, "应用平台参数错误！");
		}if (StringUtils.isBlank(pid)) {
			return new RSPE<String>(-2, "pid不能为空！");
		}
		Callable<RSPE<List<CatUserTreeResp>>> result = new Callable<RSPE<List<CatUserTreeResp>>>() {
			@Override
			public RSPE<List<CatUserTreeResp>> call() throws Exception {
				return new RSPE<List<CatUserTreeResp>>(catDevTreeService.getTree(pid,id));
			}
		};
		return result;
	}	
	
	//领取水果   只返回
	@PostMapping("/tree/receive")
	@ApiOperation(value = "领取水果", position =10, notes = "填写收件人信息及联系方式", response = RSPE.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "rtype", value = "客户端", example = "0", required = true, dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "vscode", value = "APP版本号", example = "1001", required = true, dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "treeId", value = "果树ID", example = "0", dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "pid", value = "用户ID", example = "8982895590", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "recipientName", value = "收件人名称", example = "1111111111", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "recipientPhone", value = "收件人手机号", example = "1111111111", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "area", value = "省市县,已逗号分隔", example = "山东省，济南市，XX区", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "address", value = "详细地址", example = "XXXX", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "uuid", value = "MD5(随机数)", example = "27b8f8538f84fa456f783e600c27dd18", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "utoken", value = "用户登录时的返回字段", example = "1001", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "token", value = "MD5(uuid_vscode_pid_rtype_time)", example = "1001", dataType = "String", paramType = "form") })
	@CheckingMD5(checkingStr = "uuid_vscode_pid_rtype", MD5 = "token", checkSingle = true)
	@CheckDevPermission
	public Object receiveTree(Integer rtype,String uuid,String recipientName,String recipientPhone,String area,String address,Integer vscode, Integer treeId,
			String pid,String utoken, String token) {
		if (StringUtils.isBlank(pid) || StringUtils.isBlank(utoken) || StringUtils.isBlank(token)) {
			return new RSPE<Object>(-2, "参数错误！");
			
		}
		if (treeId==null) {
			return new RSPE<Object>(-2, "果树ID为空！");
		}
		if (StringUtils.isBlank(recipientName)) {
			return new RSPE<Object>(-1, "收件人名称不能为空");
		}
		if (StringUtils.isBlank(recipientPhone)) {
			return new RSPE<Object>(-1, "收件人手机号不能为空");
		}
		if (StringUtils.isBlank(area)) {
			return new RSPE<Object>(-1, "收货地区不能为空");
		}
//		if (area.split(",").length<1) {
//			return new RSPE<Object>(-1, "收货地区参数错误");
//		}
		if (StringUtils.isBlank(address)) {
			return new RSPE<Object>(-1, "详细地址不能为空");
		}

		CatTreeResult treeResult = treeResultRepository.findByPidAndTreeId(pid, treeId);
		if (treeResult==null) {
			return new RSPE<Object>(-4, "果树记录不存在！");
		}
		if (treeResult.getTreeStatus()>2) {
			return new RSPE<Object>(-5, "订单已发货,若修改信息,请问题反馈给客服！");
		}
		
		return new Callable<RSPE<Object>>() {
			@Override
			public RSPE<Object> call() throws Exception {
				CatTreeOrder order=catDevTreeService.receiveTree(treeResult,recipientName,recipientPhone,area,address);;
				if (order == null) {
					return new RSPE<Object>(0, "填写失败，请稍后重试！");
				}
				return new RSPE<Object>(order);
			}
		};
	}
	
//	@PostMapping("/tree/order")
//	@ApiOperation(value = "查询订单信息", position =10, notes = "果树查询订单信息", response = CatTreeOrderResp.class)
//	@ApiImplicitParams({
//			@ApiImplicitParam(name = "rtype", value = "客户端", example = "0", required = true, dataType = "int", paramType = "form"),
//			@ApiImplicitParam(name = "vscode", value = "APP版本号", example = "1001", required = true, dataType = "int", paramType = "form"),
//			@ApiImplicitParam(name = "treeId", value = "果树ID", example = "0", dataType = "int", paramType = "form"),
//			@ApiImplicitParam(name = "pid", value = "用户登录时的返回字段", example = "8982895590", dataType = "String", paramType = "form"),
//			@ApiImplicitParam(name = "uuid", value = "MD5(随机数)", example = "27b8f8538f84fa456f783e600c27dd18", required = true, dataType = "String", paramType = "form"),
//			@ApiImplicitParam(name = "utoken", value = "用户登录时的返回字段", example = "1001", dataType = "String", paramType = "form"),
//			@ApiImplicitParam(name = "token", value = "MD5(uuid_vscode_pid_rtype_time)", example = "1001", dataType = "String", paramType = "form") })
//	@CheckingMD5(checkingStr = "uuid_vscode_pid_rtype", MD5 = "token")
//	@CheckDevPermission
//	public Object getTreeOrderInfo(Integer rtype,String uuid,Integer vscode, Integer treeId,
//			String pid,String utoken, String token) {
//		if (StringUtils.isBlank(pid) || StringUtils.isBlank(utoken) || StringUtils.isBlank(token)) {
//			return new RSPE<Object>(-2, "参数错误！");
//		}
//		if (treeId==null) {
//			return new RSPE<Object>(-2, "果树ID为空！");
//		}
//		CatTreeOrder treeOrder = catTreeOrderRepository.findByPidAndTreeId(pid, treeId);
//		if (treeOrder==null) {
//			return new RSPE<Object>(-4, "订单记录不存在！");
//		}
//		
//		CatTreeOrderResp orderResp = new CatTreeOrderResp();
//		BeanUtils.copyProperties(treeOrder, orderResp);	
//		return new Callable<RSPE<CatTreeOrderResp>>() {
//			@Override
//			public RSPE<CatTreeOrderResp> call() throws Exception {
//				CatTreeDetailResp re = catDevTreeService.getTreeDetail(pid,treeId);
//				orderResp.setTreeDetail(re);
//				if (re == null) {
//					return new RSPE<CatTreeOrderResp>(-3, "查询订单信息失败！");
//				}
//				return new RSPE<CatTreeOrderResp>(orderResp);
//			}
//		};
//	}
	
	@PostMapping("/tree/next")
	@ApiOperation(value = "删除果园历史种树信息", notes = "再次种树", consumes = "application/x-www-form-urlencoded", position = 5, response = CatUserTreeResp.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "rtype", value = "应用平台(0.安卓、1.IOS)", example = "0", required = true, dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "utoken", value = "用户登录时的返回字段", example = "1001", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "pid", value = "用户id", example = "5516603495", dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "id", value = "果树id", example = "0", dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "uuid", value = "MD5(随机数)", example = "27b8f8538f84fa456f783e600c27dd18", required = true, dataType = "String", paramType = "form"),
			@ApiImplicitParam(name = "token", value = "MD5(rtype_utoken_pid_id_time)", example = "1001", required = true, dataType = "String", paramType = "form") })
	@CheckDevPermission
	//@CheckingMD5(checkingStr = "rtype_utoken_pid_id_uuid", MD5 = "token")
	public Object getNextTree(Integer rtype,String pid,Integer id,String utoken, String uuid, String token) {
		if (rtype == null || (rtype != 0 && rtype != 1)) {
			return new RSPE<Object>(-3, "应用平台参数错误！");
		}if (StringUtils.isBlank(pid)) {
			return new RSPE<String>(-2, "pid不能为空！");
		}
		Callable<RSPE<List<CatUserTreeResp>>> result = new Callable<RSPE<List<CatUserTreeResp>>>() {
			@Override
			public RSPE<List<CatUserTreeResp>> call() throws Exception {
				return new RSPE<List<CatUserTreeResp>>(catDevTreeService.getNextTree(pid,id));
			}
		};
		return result;
	}	
}